﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using FinPlusWCFService;
using FinPlusCommon;


namespace Client
{
    class Program
    {
        static RequestCallback callback;

        static void Main(string[] args)
        {
            FunctionService f = new FunctionService();
            f.GetFunctions("Query", "Trade", "$group$,Trade;$where$,Name = 'FunctionName' AND Value = 'Repo'");
            
            callback = new RequestCallback();
            InstanceContext context = new InstanceContext(callback);

            using (var factory = new DuplexChannelFactory<IFunctionService>(context, new NetTcpBinding(), "net.tcp://localhost:8080/finplusItemservice"))
            {
                IFunctionService channel = factory.CreateChannel();
                channel.GetFunctions("Query", "Data", "$group$,Trade;$where$,Name = 'FunctionName' AND Value = 'Repo'");
            }
 
            Console.WriteLine("enter to exit");
            Console.ReadLine();
        }
    }

    public class RequestCallback : IFunctionCallback
    {

        public void SendResult(string id, IEnumerable<Item> function, ChangeType changeType)
        {
            //get back functions here then you would add to collection thats bound to a control
        }
    }
}
